package BaseEnvi;

import edu.scau.comeva.rigcontrol.util.HibernateAnnotacionUitl;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import static org.junit.Assert.*;

/**
 * Created with IntelliJ IDEA.
 * User: Dan
 * Date: 13-8-17
 * Time: 上午1:11
 * To change this template use File | Settings | File Templates.
 */
public class HiberTestCase {
    public static SessionFactory sessionFactory;
    public Session session;

    @BeforeClass
    public static void beforeclass(){
        sessionFactory = HibernateAnnotacionUitl.getSessionFactory();
    }

    @Before
    public void before(){
        session = sessionFactory.openSession();
        session.beginTransaction();
    }

    @After
    public void after(){
        session.beginTransaction().commit();
        session.clear();
        session.close();
    }

    @AfterClass
    public static void afterclass(){
        sessionFactory.close();
    }
}
